// GL && HF
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
const int inf = 1 << 30;

int T, n, m;
db L, V, d[100010], v[100010], a[100010], p[100010];
bool b[100010];
set<db> c;

inline bool check(int i) {
    if (!a[i]) {
        if (v[i] > V) return true;
        return false;
    } else if (a[i] < 0) {
        if (v[i] <= V) return false;
        else {
            db lt = 0, rt = 1e3 + 1;
            while (lt + 1 < rt) {
                db mt = (lt + rt) / 2;
                if (v[i] * mt + 0.5 * a[i] * mt * mt > V) lt = mt;
                else rt = mt;
            }
            if (d[i] + v[i] * lt + 0.5 * a[i] * lt * lt > L) return false;
            auto it = c.upper_bound(d[i] + v[i] * lt + 0.5 * a[i] * lt * lt);
            if (it == c.begin()) return false;
            it--;
            if (*it < d[i])
                return false;
            return true;
        }
    }
    db lt = 0, rt = 1e3 + 1;
    while (lt + 1 < rt) {
        db mt = (lt + rt) / 2;
        if (v[i] * mt + 0.5 * a[i] * mt * mt < V) lt = mt;
        else rt = mt;
    }
    if (d[i] + v[i] * rt + 0.5 * a[i] * rt * rt > L) return false;
    auto it = c.lower_bound(d[i] + v[i] * rt + 0.5 * a[i] * rt * rt);
    if (it == c.end())
        return false;
    return true;
}

int main() {
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);

    scanf("%d", &T);
    for (; T--; ) {
        c.clear();
        scanf("%d%d%lf%lf", &n, &m, &L, &V);
        for (int i = 1; i <= n; i++)
            scanf("%lf%lf%lf", &d[i], &v[i], &a[i]);
        for (int i = 1; i <= m; i++) {
            scanf("%lf", &p[i]);
            c.insert(p[i]);
        }
        int cnt= 0;
        for (int i = 1; i <= n; i++)
            if (check(i))
                ++cnt;
        printf("%d ", cnt);

        int ans = 0;
        if (n <= 20 && m <= 20)
            for (int i = 0; i < (1 << m); i++) {
                for (int t = i, cnt2 = n; t; t /= 2, --cnt2)
                    if (t & 1)
                        b[cnt2] = true;
                int cnt2 = 0;
                for (int j = 1; j <= m; j++)
                    if (!b[j])
                        c.erase(p[j]);
                for (int j = 1; j <= n; j++)
                    if (check(j))
                        ++cnt2;
                if (cnt2 == cnt)
                    ans++;
                for (int j = 1; j <= m; j++)
                    if (!b[j])
                        c.insert(p[j]);
            }
        else {
            ans = m - 1;
            sort(p + 1, p + m + 1);
            c.clear();
            int cnt2 = 0;
            for (int i = 1; i <= n; i++)
                if (check())
                    cnt2++;
            if (cnt2 == cnt) ans = m;
        }
        printf("%d\n", ans);
    }
    return 0;
}
